package file;

import java.io.File;

public class ListFilesDemo {
    public static void main(String[] args) {
        File dir = new File(".");;
        if (dir.isDirectory()){
            File[] files = dir.listFiles();
            System.out.println("共有多少个文件："+files.length);
            for (int i = 0; i < files.length; i++) {
                System.out.println(files[i].getName());
            }
        }else {
            System.out.println("该目录不存在！");
        }
    }
}
